
#ifndef DEBUG_H

#define DEBUG_H

#ifdef DEBUG

#include <stdio.h>

#include "loaded_file.h"
#include "generic_table.h"
#include "lexic_analyzer.h"
#include "syntax_tree.h"
#include "semantic_analyzer.h"

#include <string>
using namespace std;

class Debug
{
public:
	Debug();
	~Debug();
	void ReportLine(char * str);
	void ReportLiterally(char * str);
		
	void OutputLexicToXML(LexicUnits * lu);
	void OutputSyntaxToXML(AbstractSyntaxTree * ast, LexicUnits * lus);
	void OutputSemanticsStructuresToXML(SemanticAnalyzer * sa, LexicUnits * lus);
	void OutputSemanticsStructuresFlattenToXML(SemanticAnalyzer * sa, LexicUnits * lus);

	void PrintLoadedFiles(GenericTable<LoadedFile> * loadedFiles);


private:
	FILE * debugFile;

	void PrintLexicUnitToXML(FILE * fo, LexicUnit * lu, LexicUnits * lus);
	void MakeStringOfLexicUnitType(char * str, LexicUnitType lut);

	void PrintSyntaxTreeNodeToXML(FILE * fo, SyntaxTreeNode * node, int indent, LexicUnits * lus);
	void PrintSpaces(FILE * fo, int count);

	static string CodeForXML(const char * s);
};

#endif

#endif

